package com.opmsys.pojo.vo;

import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.opmsys.pojo.entity.Person;
import lombok.Data;

import java.text.SimpleDateFormat;
import java.util.Date;

@Data
public class PersonInfo {
    //    用户id
    private Integer id;
    //    用户名
    private String name;
    //    用户头像
    private  String headImg;
    //    用户工号
    private Long number;
    //    用户类型/状态
    private Integer status;
    //    用户工龄
    private Long workAge;

    public  PersonInfo(Person person){
        id = person.getId();
        name = person.getName();
        headImg = person.getHeadImg();
        number = person.getNumber();
        status = person.getStatus();
        Date entryDate = DateUtil.parse(person.getEntryDate());
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        Date nowDate = new Date();
        workAge = DateUtil.between(nowDate, entryDate, DateUnit.WEEK);
    }
}
